//
//  BSTDateExtension.swift
//  SwiftBaseTool
//
//  Created by taolei-mac on 2018/8/8.
//  Copyright © 2018年 taolei-mac. All rights reserved.
//

import Foundation

public extension Date {
    
    public func dateConvertStringWithFormat(format: BSTDateFormat) -> String {
        return self.dateConvertString(formatString: format.stringValue())
    }
    
    // 根据formatter将时间转成字符串
    public func dateConvertString(formatString: String) -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateStyle = .none
        dateFormatter.locale = Locale.init(identifier: "zh_CN")
        dateFormatter.dateFormat = formatString
        return dateFormatter.string(from: self)
    }
    
}
